1. Field of the Invention
The present invention relates to image encoding apparatuses, image encoding methods, programs, and recording media. More specifically, the present invention relates to prediction encoding apparatuses.
2. Description of the Related Art
MPEG4 and H.264 are known as standards for compression encoding of macro blocks of moving-picture data using inter-frame and intra-frame correlations. In these standards, it is possible to achieve high-quality compression by using an inter-frame prediction method when temporal correlation between frames is high while using an intra-frame prediction method when correlation within a frame is high. Particularly, in the H.264 standard, a plurality of prediction units or a plurality of prediction modes is prepared for each of inter-frame prediction and intra-frame prediction so that methods of compression encoding are enhanced compared with those in MPEG4.
The inter-frame prediction is effective in cases where motion of objects is relatively small. In the inter-frame prediction, an image having a high correlation with a current macro block is extracted from a temporally preceding or succeeding frame, and a difference between the image and the macro block is encoded. At that time, a motion vector indicating which portion has been extracted is also encoded.
In contrast, the intra-frame prediction is effective when correlation within a frame is high. In the intra-frame prediction, prediction errors are calculated on the basis of correlation between a current macro block and an adjacent macro block, or correlation within a macro block. Thus, even in cases where motion of objects is relatively large, making it difficult to determine an optimal motion vector by inter-frame prediction, it may be possible to achieve relatively efficient encoding using intra-frame prediction.
In a case where these two types of prediction can be used, it is necessary to determine which types of prediction will be efficient to achieve high-quality compression. When there exists no particular restriction on processing time (e.g., in a case of compressing uncompressed moving-picture data that has already been recorded), it is possible to execute encoding using each of all the possible methods, units, and modes and then select an optimal method according to the results. However, for example, when encoding is to be executed in real time while shooting a moving picture using a video camera, the above method is so complex and resource intensive that it is difficult to use the method. Therefore, it is necessary to select either inter-frame encoding or intra-frame encoding on the basis of an evaluation value.
As an example of related art for this purpose, according to Japanese Patent Laid-Open No. 2005-244749, an evaluation value for intra-frame-prediction encoding is calculated on the basis of input pixels alone before actually executing intra-frame-prediction encoding, and the evaluation value is used to select an encoding method. According to the related art, since an evaluation value representing a feature of inter-frame-prediction encoding is calculated using input pixels alone, processing for selection of an encoding method can be simplified significantly, and it is possible to considerably reduce processing time needed for the selection.
In a moving-picture encoding apparatus described in Japanese Patent Laid-Open No. 2005-244749, an evaluation value regarding intra-frame prediction, representing correlation between input pixels, is calculated, thereby estimating prediction errors that occur through intra-frame prediction before actually executing encoding. In the case of H.264, however, pixels that are used to calculate predicted values for inter-frame-prediction encoding are not input pixels. In H.264, the pixels actually used to calculate predicted values are pixels obtained by executing an integer transform and quantization on prediction errors and then executing a dequantization and inverse transform on the results (hereinafter referred to as locally decoded pixels). Therefore, if the techniques described in Japanese Patent Laid-Open No. 2005-244749 are used in H.264 encoding, problems arise because pixels are used that are different from the pixels that more favorably should be used. This can result in an inappropriate decision regarding whether to use inter-frame prediction or intra-frame prediction. An inaccurate decision regarding whether inter-frame prediction or intra-frame prediction should be used can reduce the quality of the compression encoding. Furthermore, there exists a similar problem regarding selection between a plurality of prediction methods of intra-frame prediction encoding.
In the case of compression at a low compression rate, where compression encoding typically causes little distortion, differences between input pixels and locally decoded pixels are small. Thus, even if inter-frame or intra-frame prediction is selected using input pixels instead of locally decoded pixels, the accuracy of selection is not considerably degraded. In contrast, in the case of compression at a high compression rate, where compression encoding typically causes much distortion, locally decoded pixels are considerably distorted relative to input pixels. Therefore, where the determination regarding whether to use inter-frame prediction or intra-frame prediction is based on locally decoded pixels it has been difficult to generate optimal prediction errors.